<template>
	<view>
		<view class="address" @click="Toaddress()" v-if="!address2">
			<view class="UserInfo">
				<text class="Name">{{address[0].true_name}}</text> <text class="Phone">{{address[0].mob_phone}}</text>
			</view>
			<view class="addInfo FleBox">
				<view class="">
					<image src="@/static/images/dwIco.png" mode="" class="dwIco"></image>
					<text>{{address[0].area_info}}{{address[0].address}}</text>
				</view>
				<image src="@/static/images/right_arrow.png" mode="" class="right_arrow"></image>
			</view>
		</view>
		<view class="address" @click="Toaddress()" v-if="address2">
			<view class="UserInfo">
				<text class="Name">{{address2.true_name}}</text> <text class="Phone">{{address2.mob_phone}}</text>
			</view>
			<view class="addInfo FleBox">
				<view class="">
					<image src="@/static/images/dwIco.png" mode="" class="dwIco"></image>
					<text>{{address2.area_info}}{{address2.address}}</text>
				</view>
				<image src="@/static/images/right_arrow.png" mode="" class="right_arrow"></image>
			</view>
		</view>
		<view class="commodity FleBox">
			<view class="commImage">
				<image :src="shopInfo.pgoods_image" mode=""></image>
			</view>
			<view class="">
				<view class="Name">
					{{shopInfo.pgoods_name}}
				</view>
				<view class="InfoBox">
					<view class="Num">
						兑换数量：1					</view>
					<view class="Price">
						兑换所需积分：{{shopInfo.pgoods_points}}积分
					</view>
				</view>
			</view>
		</view>
		
		<view class="confirms" @click="confirms()">确认订单</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pid:1,
				shopInfo:"",
				address:"",
				address2:""
			}
		},
		onLoad(e) {
			
			if(e.pid){
				this.pid=e.pid;
			}
			if(e.address){
				this.address2 =JSON.parse(e.address);
				console.log(this.address2)
			}
			this.GetInfo();
		},
		// onLoad() {
		// 	this.GetInfo();
		// 	// page.onLoad()
		// },
		methods: {
			Toaddress(){
				uni.navigateTo({
					url:"/member/address/list?gouwujin=gouwujin"
				})
			},
			GetInfo(){//获取订单信息
				this.$util.request({
					url:'/mobile/index.php?act=pointcart&op=step1',
					data:{pid:this.pid},
					method:'post'
				}).then(res=>{
					if(res.error_code==0){
						this.shopInfo=res.datas.list[0];
						this.address=res.datas.address_list;
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
			},
			
			
			
			confirms(){
				this.$util.request({
					url:'/mobile/index.php?act=pointcart&op=step2',
					method:'POST',
					data:{
						pid:this.pid,
						address_options:this.address[0].address_id
					}
				}).then(res=>{
					if(res.error_code==0){
						uni.redirectTo({
							url:"complete"
						})
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
				
			}
		}
	}
</script>

<style scoped="scoped">
	.FleBox{
		display: flex;
		/* justify-content: space-between; */
		align-items: center;
	}
	.address{
		background-color: #FFFFFF;
		padding: 20rpx 40rpx;
		margin: 30rpx 0;
	}
	.UserInfo{
		font-size: 28rpx;
		color: #999999;
	}
	.UserInfo .Name{
		color: #444444;
		font-size: 35rpx;
		margin-right: 20rpx;
		
	}
	.address .addInfo{
		margin-top: 20rpx;
		justify-content: space-between;
	}
	.address .dwIco{
		width: 24rpx;
		height: 32rpx;
		vertical-align: middle;
		margin-right: 10rpx;
	}
	.address .right_arrow{
		width: 12rpx;
		height: 20rpx;
	}
	.commodity{
		background-color: #FFFFFF;
		padding: 20rpx 40rpx;
	}
	.commodity .commImage image{
		width: 170rpx;
		height: 170rpx;
		margin-right: 20rpx;
		border-radius: 10rpx;
	}
	.commodity .Name{
		font-size: 30rpx;
		color: #333333;
		font-weight: bold;
		line-height: 42rpx;
		height: 80rpx;
		display:-webkit-box;
		-webkit-box-orient:vertical;
		-webkit-line-clamp:2;
		overflow: hidden;
		margin-bottom: 15rpx;
	}
	.commodity .InfoBox .Num,.commodity .InfoBox .Price{
		line-height: 40rpx;
		color: #999999;
	}
	.confirms{
		width: 660rpx;
		background-color: #e61465;
		line-height: 60rpx;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: center;
		position: fixed;
		bottom: 40rpx;
		margin: 0 40rpx;
		box-sizing: border-box;
		}
</style>
